
#include "../../Command.h"
#include "../../User.h"

#include "../../NResource/Static.h"

#include "../../NLogic/Card.h"
#include "../../NLogic/Item.h"
#include "../../NLogic/Bag.h"
#include "../../NLogic/Space.h"
#include "../../NLogic/Static.h"
#include "../../NLogic/VirtualCurrency.h"
#include "../../NUtil/Utils.h"

namespace ProjectZ { namespace NCommand {


void Command::CS_REQ_DUNGEON_MOB_INFO(User * pUser, ::Network::Packet * pPacket)
{
/*	CS_REQ_DUNGEON_MOB_INFO				0x1122
{

}

SC_REQ_DUNGEON_MOB_INFO				0x1123
{
	u8 count			/// 모든 몬스터의 HP정보
	{
		u32 u32gid;		/// 몬스터 GID
		u32 u32hp;		/// 0 이면 죽음 0 이상이면 클라이언트에서 부활처리
	}
}*/

	PREPARE_PACKET;

	NLogic::Space * pSpace = pUser->GetSpace();
	if (NULL == pSpace)
	{
		DEBUGLOG("WARNING: CN_DUNGEON_CARD_REWARD GID %d, pSpace is NULL", pUser->GetUserSeq());
		return;
	}

	if (false == pSpace->IsDungeon())
	{
		DEBUGLOG("CS_DUNGEON_CARD_REWARD : space is not single or party dungeion");
		return;
	}

	NLogic::Space::MONSTERTREE & mosterTree = pSpace->GetMonsterTree();

	std::vector<NLogic::Monster * > clsVector;
	std::for_each(mosterTree.begin(), mosterTree.end(), [&](NLogic::Space::MONSTERTREE::value_type & pair) {
		if (pair.second->GetMonsterType() == NLogic::Monster::MonsterType::MONSTER && pair.second->GetData().hp > 0)
		{
			clsVector.push_back(pair.second);
		}
	} );

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	* pAck << static_cast<uint8_t>(clsVector.size());
	std::for_each(clsVector.begin(), clsVector.end(), [&](NLogic::Monster * pMonster) {
		* pAck << static_cast<uint32_t>(pMonster->GetData().gid);
		* pAck << static_cast<uint32_t>(pMonster->GetData().hp);
	} );
	pAck->MakePacket(CMD_SC_REQ_DUNGEON_MOB_INFO);
	pUser->Send(pAck);

	clsVector.clear();

}

} /*NCommand*/ } /*ProjectZ*/
